package com.p7.framework.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.p7.framework.common.ResultBean;
import com.p7.framework.service.HomeService;

@Controller
@RequestMapping("/home")
public class HelloController {

	@Autowired
	private HomeService homeService;

	@GetMapping()
	public ResultBean home(@RequestParam(value = "homeName", required = true) String homeName) {

		String home = homeService.home(homeName);

		return new ResultBean(home);
	}
	
	@ResponseBody
	@GetMapping("/home2")
	public ResultBean home2(@RequestParam(value = "homeName", required = true) String homeName) {

		String home = homeService.home(homeName);

		return new ResultBean(home);
	}

	@GetMapping("/homeStrJson")
	@ResponseBody
	public String homeStrJson(String homeName) {

		String home = homeService.home(homeName);

		return home;
	}

	@GetMapping("/homeObjJson")
	@ResponseBody
	public ResultBean homeObjJson(String homeName) {

		String home = homeService.home(homeName);

		return new ResultBean(home);
	}

}
